﻿using Application.App;
using Infrastructure.Error;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace FacadeApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OtherController : ControllerBase
    {

        public OtherApplication otherApplication { get; set; }
        public ILogger<OtherController> _logger { get; set; }

        [HttpGet]
        public ActionResult GetBannerList(int category)
        {
            try
            {
                var data = otherApplication.GetBannerList(category);
                return this.Success(data, "成功!");
            }
            catch (BizException ex)
            {
                return this.FailResult(ex.data, ex.Message);
            }
            catch (Exception ex)
            {
                _logger.LogException(ex);
                return this.FailResult(null, "系统繁忙，请稍后重试!");
            }
        }

        /// <summary>
        /// 新人任务页面配置
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult GetNewRewardInfo()
        {
            try
            {
                var data = otherApplication.GetNewRewardInfo();
                return this.Success(data, "成功!");
            }
            catch (BizException ex)
            {
                return this.FailResult(ex.data, ex.Message);
            }
            catch (Exception ex)
            {
                _logger.LogException(ex);
                return this.FailResult(null, "系统繁忙，请稍后重试!");
            }
        }
    }
}
